/**
 * 功能描述
 * 服务器交互
 */

define(function (require, exports, module) {
    var aw = require("ajaxwrapper");
    var store = require("store");
	var activeUser = store.get("user");
	
    module.exports = {
		querySrviceClass:function(callback){
    		aw.ajax({
                url: "api/serviceclass/query",
                data: {
                	statusIn:"Setting",
                	fetchProperties:"pkServiceClass,name"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	},
    	queryDishType:function(callback){
    		aw.ajax({
                url: "api/cater/dishtype/query",
                data: {
                	servicePoint:activeUser.servicePoint.pkServicePoint,
                	fetchProperties:"pkDishType,name"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	},
    	queryGoods:function(callback){
    		aw.ajax({
                url: "api/goodstype/query",
                data: {
                	fetchProperties:"pkGoodsType,name"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	},
    	queryServiceItems:function(callback){
    		aw.ajax({
                url: "api/serpointsertyperelation/querybystatuswithsetting",
                data: {
                	servicePoint:activeUser.servicePoint.pkServicePoint,
                	type:"ServiceType",
                	fetchProperties:"*,servicePackage.*,serviceType.*,serviceType.unit,serviceType.name," +
                			"serviceType.serviceClass.name,serviceType.serviceClass.pkServiceClass," +
                			"feeProject.name,feeProject.unit,feeProject.feeType.pkFeeType,feeProject.feeType.name," +
                			"classifyContent.name,classifyContent.unit,goods.name,goods.pkGoods,goods.unit.name,businessTypes.*"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	},
    	queryGoodsItems:function(callback){
    		aw.ajax({
                url: "api/serpointsertyperelation/querybystatuswithsetting",
                data: {
                	servicePoint:activeUser.servicePoint.pkServicePoint,
                	type:"Goods",
                	fetchProperties:"*,servicePackage.*,goods.*," +
                			"goods.goodsType.pkGoodsType,goods.goodsType.name," +
                			"feeProject.name,feeProject.unit,feeProject.feeType.pkFeeType,feeProject.feeType.name," +
                			"classifyContent.name,classifyContent.unit,goods.name,goods.pkGoods,goods.unit.name,businessTypes.*"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	},
    	queryDishItems:function(callback){
    		aw.ajax({
                url: "api/cate/dishmenu/querytodaydish",
                data: {
                	"menuDate":moment().startOf("day").format("x"),
                	"menuDateEnd":moment().endOf("day").format("x"),
                	servicePoint: activeUser.servicePoint.pkServicePoint,
                	fetchProperties:"*,dish.name,dish.remark,dish.dishType.pkDishType"
                },
                dataType: "json",
                success: function(data) {
                	callback(data);
                }
            });
    	}
    };
});
